<!-- 公共文件 start -->
@extends('admin.public.base')
<!-- 公共文件 end -->
@section('content')
    <div class="x-nav">
    <span class="layui-breadcrumb mbx_fl_10">
        <a href="">首页</a>
        <a href="">库存管理</a>
        <a><cite>库存变动记录</cite></a>
    </span>
        <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
           onclick="location.reload()" title="刷新">
            <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
        </a>
    </div>
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-body ">
                        <form class="layui-form layui-col-space5">
                            <div class="layui-inline layui-show-xs-block">
                                <input type="text" name="name" placeholder="商品关键字" autocomplete="off"
                                       value="{{ Request()->get('name') }}" class="layui-input">
                            </div>
                            <div class="layui-inline layui-show-xs-block">
                                <input type="text" name="goods_sn" placeholder="商品编号" autocomplete="off"
                                       value="{{ Request()->get('goods_sn') }}" class="layui-input">
                            </div>
                            <div class="layui-inline layui-show-xs-block">
                                <button class="layui-btn" lay-submit="" lay-filter="sreach">
                                    <i class="layui-icon">&#xe615;</i>
                                </button>
                                <input type="hidden" id="export_excel" name="export_excel" value="0">
                                <button id="export_excel_btn" class="layui-btn" lay-submit="" lay-filter="sreach"><i
                                        class="layui-icon">&#xe65b;</i>导出Excel
                                </button>
                            </div>
                        </form>
                    </div>
                    <div class="layui-card-body ">
                        <table class="layui-table layui-form" style="width: 100%">
                            <thead>
                            <tr>
                                <th>商品分类</th>
                                <th>商品编号</th>
                                <th>商品图片</th>
                                <th>商品名称</th>
                                <th>商品单价</th>
                                <th>当前总库存</th>
                                <th>当前可售库存</th>
                                <th>操作</th>
                            </thead>
                            <tbody>
                            @foreach($data as $item)
                                <tr>
                                    <td>
                                        {{$item['cate_name']}}
                                    </td>
                                    <td>
                                        {{$item['goods_sn']}}
                                    </td>
                                    <td>
                                        <img src="{{$item['goods_img']}}" style="width: 50px;">
                                    </td>
                                    <td>
                                        {{$item['goods_name']}}
                                    </td>
                                    <td>
                                        {{$item['goods_price']}}
                                    </td>
                                    <td>
                                        {{$item['goods_total_num']}}
                                    </td>
                                    <td>
                                        {{$item['goods_sale_num']}}
                                    </td>
                                    <td>
                                        <button class="layui-btn layui-btn layui-btn-xs"
                                                onclick="xadmin.open('单品入库','/admin/stock/repertoryOneEnter?goods_id={{$item['id']}}',1100,630)">
                                            <i class="iconfont">&#xe6b9;</i>单品入库
                                        </button>
                                        <button class="layui-btn layui-btn layui-btn-danger"
                                                onclick="xadmin.open('单品出库','/admin/stock/repertoryOneOut?goods_id={{$item['id']}}',1100,630)">
                                            <i class="iconfont">&#xe6fe;</i>单品出库
                                        </button>
                                    </td>
                                </tr>
                            @endforeach
                            </tbody>
                        </table>
                    </div>
                    <div class="layui-card-body ">
                        <div class="page">
                            {{ $data->links('admin/public/page') }}
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>
        layui.use(['laydate', 'form'], function () {
            var laydate = layui.laydate;
            var form = layui.form;

            //执行一个laydate实例
            laydate.render({
                elem: '#start', //指定元素
                type: 'datetime'
            });

            //执行一个laydate实例
            laydate.render({
                elem: '#end', //指定元素
                type: 'datetime'
            });
        });

        var cateIds = [];

        function getCateId(cateId) {
            $("tbody tr[fid=" + cateId + "]").each(function (index, el) {
                id = $(el).attr('cate-id');
                cateIds.push(id);
                getCateId(id);
            });
        }

        $("#export_excel_btn").on('click', function () {
            layer.load(2, {
                time: 10000
            });
            $("#export_excel").val(1)
        });
        $("#search").on('click', function () {
            layer.load(2, {
                time: 10000
            });
            $("#export_excel").val(0);
        });
    </script>
@endsection
